
static CFont[] fonts;
static byte[] charW;
static String stMap;
//public static final FONT_COUNT = 5;

	public static void initFontSystem() {
		if(fonts==null)
		fonts = new CFont[5];
	}

	public static void loadFont(int fontId) {
		if (fonts[fontId] != null)
			return;
		switch (fontId) {
		case FONT_10:
			stMap = "0123456789.,:!?()-'/ABCDEFGHIJKLMNOPQRSTUVWXYZÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ";
			charW = new byte[] { 7, 4, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 6,
					5, 5, 4, 2, 5, 8, 7, 8, 7, 6, 6, 8, 8, 3, 6, 7, 6, 10, 9,
					8, 8, 8, 8, 8, 7, 8, 8, 10, 9, 9, 7, 8, 8, 8, 8, 8, 8, 8,
					8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
					6, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
					8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 };
			try{		
			fonts[fontId] = new CFont("fcg10.png", charW, 14, 3, stMap);
			}catch(Exception e){
			System.out.println("********  khong tao duoc CFOnt  ***********");
			}			
			
			break;
		case FONT_14:
			stMap = "0123456789.,:!?()-'/ABCDEFGHIJKLMNOPQRSTUVWXYZÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ";
			charW = new byte[] { 8, 5, 8, 8,
					8,
					8,
					8,
					8,
					8,
					8,// 0-9
					4, 4, 4, 4, 8, 6, 6, 6, 3, 7, 10, 10, 10, 10, 8, 8, 10, 10,
					5, 8, 9, 8, 13, 11, 10, 10, 10, 10, 10, 9, 10, 10, 13, 11,
					11, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
					10, 10, 10, 10, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 5, 5,
					5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
					10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
					10, 10, 10, 10, 10, 10 };
			fonts[fontId] = new CFont("fcg14.png", charW, 20, 4, stMap);
			break;
		case FONT_14_2:
			stMap = "0123456789.,:!?()-'/ABCDEFGHIJKLMNOPQRSTUVWXYZÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ";
			charW = new byte[] { 8, 5, 8, 8,
					8,
					8,
					8,
					8,
					8,
					8,// 0-9
					4, 4, 4, 4, 8, 6, 6, 6, 3, 7, 10, 10, 10, 10, 8, 8, 10, 10,
					5, 8, 9, 8, 13, 11, 10, 10, 10, 10, 10, 9, 10, 10, 13, 11,
					11, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
					10, 10, 10, 10, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 5, 5,
					5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
					10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
					10, 10, 10, 10, 10, 10 };
			fonts[fontId] = new CFont("fcg14_2.png", charW, 20, 4, stMap);
			break;
		}
	}

	public static void freeFont(int fontId) {
		fonts[fontId] = null;
	}

	public static void drawString(Graphics g, String s, int fontId, int x,
			int y, int align) {		
		
			if(fonts==null)
			fonts = new CFont[5];	
			if (fonts[fontId] == null)
			loadFont(fontId);
		try{	
			fonts[fontId].drawString(s, x, y, align, g);
			
		}catch(Exception e){
			System.out.println("Ve duoc chu roi nhung bi ngoai le");
		}
		// NOT YET RESOLVED: TWO EXCEPTION WHEN LOAD FONT AND DRAW STRING
	}
